home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / tos / progut~1 / iostream.zoo / test / tst.cc < prev   
Encoding:
C/C++ Source or Header  |  1991-09-22  |  462 b   |  24 lines

  1. #include "iostream.h"
  2. #include "stdio.h"
  3.  
  4. main(int argc, char** argv)
  5. {
  6.     for (int i = 0; i < argc; i++) {
  7.     fprintf(stdout, "arg%d=%s ", i, argv[i]);
  8.     cout << "[" << i << " " << argv[i] << "]\n";    
  9.     }
  10.     if (argc > 1) {
  11.     FILE * stream = fopen(argv[1], "r");
  12.     if (stream == NULL) {
  13.         fprintf(stderr, "Failed to open: %s\n", argv[1]);
  14.         return 0;
  15.     }
  16.     for (;;) {
  17.         int ch = getc(stream);
  18.         if (ch == EOF)
  19.         break;
  20.         putc(ch, stdout);
  21.     }
  22.     }
  23. }
  24.